package com.handong.handserialprogram.module.base;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

/**
 * BasePagerAdapter:和ViewPager结合使用。
 * Created by userKey on 2017/8/3.
 */

public class BasePagerAdapter extends FragmentPagerAdapter {

    private Fragment[] mFragmentsArr;
    private String[] mTitleName;

    public BasePagerAdapter(FragmentManager fm, Fragment[] fragmentsArr, String[] titleName) {
        super(fm);
        mFragmentsArr = fragmentsArr;
        mTitleName = titleName;
    }

    @Override
    public Fragment getItem(int position) {
        return mFragmentsArr[position];
    }

    @Override
    public int getCount() {
        return mFragmentsArr == null ? 0 : mFragmentsArr.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTitleName[position];
    }
}
